'use strict';

const Controller = require('../base');

class SysResetController extends Controller {

    async changePsw() {
        const { ctx } = this;
        const body = ctx.request.body;
        ctx.validate({
            username: { type: 'string', required: true },
            pass: { type: 'string', required: true },
            old_pass: { type: 'string', required: true },
        }, body);
        const res = await ctx.service.sys.reset.changePsw(body);
        if (res.success) {
            this.success(res.msg);
        } else {
            this.error(res.msg);
        }
    }
}

module.exports = SysResetController;
